﻿using Models.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using yymbDAL;

namespace yymbBLL
{
    public class My_homeManger
    {
        private My_home db;
        public My_homeManger()
        {
            db = new My_home();
        }
        /// <summary>
        /// 我的首页侧边个人信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Information Side_info(int id)
        {
            return db.Side_info(id);
        }
        /// <summary>
        /// 用户关注数
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int use_atte(int id)
        {
            return db.use_atte(id);
        }
        /// <summary>
        /// 用户粉丝数
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int use_fans(int id)
        {
            return db.use_fans(id);
        }
        /// <summary>
        /// 用户微博数
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int use_mibls(int id)
        {
            return db.use_mibls(id);
        }
        /// <summary>
        /// 热门话题
        /// </summary>
        /// <returns></returns>
        //public dynamic hot_topic()
        //{
        //    return data;
        //}
        /// <summary>
        /// 用户首页发微博
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Microblog(int uid, string content, string url, List<WB_pic> pic)
        {
            return db.Microblog(uid, content, url, pic);
        }
        /// <summary>
        /// 用户微博(全部)
        /// </summary>
        /// <returns></returns>
        public List<Microblog> Oth_use_mibl(int id)
        {
            return db.Oth_use_mibl(id);
        }
        /// <summary>
        /// 相互关注的微博
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public List<Microblog> Mut_atte(int id)
        {
            return db.Mut_atte(id);

            //using (yymbDBEntities db = new yymbDBEntities())
            //{
            //    StringBuilder str = new StringBuilder("2123");
            //    str.Append("111");
            //    foreach (var item in Mut_atte_bool(id))
            //    {
            //        string stra = @"select i.Nickname,i.Photo,mb.Content,mb.Release_time from [User] as u" +
            //        "left join Microblog as mb on mb.UserID=u.UserID" +
            //        "left join Information as i on i.UserID=u.UserID" +
            //        "left join User_rs as ur on ur.UserID=u.UserID" +
            //        "where u.UserID=" + id + " order by mb.Release_time";

            //    }

            //    List<Class.Mut_atte> mut = new List<Class.Mut_atte>();
            //    foreach (var item in Mut_atte_bool(id))
            //    {
            //        List<Class.Mut_atte> data = Mut_atte_select(item);
            //        mut.Add(data);
            //    }

            //    return data;
            //}
        }
        /// <summary>
        /// 用户微博（其他的分类）
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public Microblog Oth_use_mibl(int id, string type)
        {
            return db.Oth_use_mibl(id,type);
        }
        /// <summary>
        /// 用户微博搜索（关注的人说的话）
        /// </summary>
        /// <param name="id"></param>
        /// <param name="str"></param>
        /// <returns></returns>
        public List<Microblog> Mibl_sear(int id, string str)
        {
            return db.Mibl_sear(id, str);
        }
        //查询出来的微博条数
        public int GetMbPage(List<Microblog> lm)
        {
            return db.GetMbPage(lm);
        }
        //查询数据库
        public List<Microblog>Mibl_sear_select(int? id, string str)
        {
            return db.Mibl_sear_select(id, str);
        }
        //我关注的人
        public List<int?> Mibl_sear_list(int id)
        {
            return db.Mibl_sear_list(id);
        }
        /// <summary>
        /// 用户微博搜索(高级搜索)
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <param name="str"></param>
        /// /// <param name="before"></param>
        /// /// <param name="now"></param>
        /// <returns></returns>
        public List<Microblog> Mibl_sear_Adva(int uid, int[] type, string str, DateTime before, DateTime now)
        {
            return db.Mibl_sear_Adva( uid,  type,  str,  before,  now);
        }
    }
}
